<template>
  <div class="container">
<!--    <el-button @click="userRegister">注册</el-button>-->
    <el-button @click="usrLogin">登录</el-button>
<!--    <div>-->
<!--      <SvgIcon name="test" class="test"></SvgIcon>-->
<!--    </div>-->
  </div>
</template>

<script>
import MToast from '@/components/MToast'
import {register,login} from '@/api'
import cookie from 'js-cookie'
import  {mapActions} from 'vuex'
export default {
  data() {
    return {}
  },
  mounted() {},
  methods: {
    ...mapActions('Chat',['connectSocket']),
    async usrLogin() {
      const params = {
        password: "123456",
        username: "钟富林2"
      }
      const res = await login(params)
      if(res?.code!==0)return
      cookie.set('token',res.data.token)
      this.connectSocket(res.data.user)
    },
    async userRegister() {
      const params = {
        password: "123456",
        username: "钟富林2"
      }
      const res = await register(params)
      if(res?.code!==0)return
      cookie.set('token',res.data.token)

    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  display: flex;
  flex-direction: column;

  .test {
    font-size: 50px;
    color: green;
  }
}

</style>
